#include <stdio.h>
#include <SDL.h>
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"


int musique(const char* musiquePath)
{
    const unsigned int windowWidth = 640;
    const unsigned int windowHeight = 480;

    SDL_Surface* pWindowSurface = NULL;
    char mustContinue = 1;
    Mix_Music *musique;
    SDL_Event event;
    pWindowSurface = SDL_SetVideoMode(windowWidth,windowHeight,32,SDL_SWSURFACE | SDL_DOUBLEBUF);
    if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024) == -1)
    {
        printf("%s", Mix_GetError());
        return(-6);
    }
    musique = Mix_LoadMUS(musiquePath);
    Mix_PlayMusic(musique, 1);
    while ( mustContinue )
    {
        while(SDL_PollEvent(&event))
        {
            if( event.type == SDL_QUIT )
            {
                mustContinue = 0;
            }
            else if( event.type == SDL_KEYDOWN )
            {
                if ( event.key.keysym.sym == SDLK_ESCAPE )
                {
                    mustContinue = 0;
                }
            }
        }
    }
    Mix_FreeMusic(musique);
    Mix_CloseAudio();
    SDL_Quit();
    return 0;
}
